# -*- coding: utf-8 -*-
import unittest
from selenium import webdriver
import time
import xlrd
from Page.loginPage import loginPage
from publicModule.login import login
from Page.noscanningPage import noscanningPage
from publicModule.noscanning import noscanning
from publicModule.policyholder import policyholder
from Page.policyholderPage import policyholderPage
class Test_Policyholder(unittest.TestCase):
    @classmethod
    def setUpClass(self):
        print('开始测试')
        self.driver = webdriver.Chrome()
        self.driver.implicitly_wait(10)
        self.driver.maximize_window()
        self.driver.get("http://10.22.26.34:8080/fwd/indexlis.jsp")
        time.sleep(2)
        self.loginPage = loginPage(self.driver)
        self.login = login(self.driver)
        self.noscanningPage=noscanningPage(self.driver)
        self.noscanning = noscanning(self.driver)
        self.noscanning1 = noscanning(self.driver)
        self.policyholder=policyholder(self.driver)
        self.policyholderPage=policyholderPage(self.driver)

    # @classmethod
    # def tearDownClass(self):
    #     print('结束测试')
    #     self.driver.quit()
    def test01(self):
        print('test01')
        filename = '..//TestData//loginData.xlsx'
        excel_open = xlrd.open_workbook(filename)
        table = excel_open.sheet_by_name('Sheet1')
        rows = table.nrows
        for i in range(2, rows):
            row_content = table.row_values(i)
            username = row_content[0]
            password = row_content[1]
            orgcode = int(row_content[2])
            login.login(self, username, password, orgcode)
    def test02(self):
        print('test02')
        noscanning.noscanning(self)
        time.sleep(1)
        noscanning.noscanning1(self)
        time.sleep(1)
        policyholder.policyholderenter(self)
        time.sleep(1)
    def test03(self):
        print('test03')
        filename = r'..\TestData\outputdata.xls'
        excel_open = xlrd.open_workbook(filename)
        table = excel_open.sheet_by_name('Sheet1')
        rows = table.nrows
        for i in range(1, rows):
            row_content = table.row_values(i)
            GrpPropNo = row_content[0]
            policyholder.query(self,GrpPropNo)
    def test04(self):
        print('公共池--个人池')
        policyholder.pool(self)
    def test05(self):
        print('基本投保信息修改')
        filename = '..//TestData//policyholderifm.xlsx'
        excel_open = xlrd.open_workbook(filename)
        table = excel_open.sheet_by_name('Sheet1')
        rows = table.nrows
        for i in range(2, rows):
            row_content = table.row_values(i)
            ChnlType = row_content[0]
        policyholder.modifyIfm(self, ChnlType)
    # def test06(self):
    #     print('团险客户经理')
    #     filename = 'C:/Users/tanjm.ext/PycharmProjects/GroupL/TestData/policyholderifm.xlsx'
    #     excel_open = xlrd.open_workbook(filename)
    #     table = excel_open.sheet_by_name('Sheet1')
    #     rows = table.nrows
    #     for i in range(2, rows):
    #         row_content = table.row_values(i)
    #         CustomerChannel = row_content[0]
    #         CommissionRate = int(row_content[1])
    #         policyholder.AgentManager(self,CustomerChannel,CommissionRate)
    def test07(self):
        print('投保人资料')
        filename = '..//TestData//policyholderifm.xlsx'
        excel_open = xlrd.open_workbook(filename)
        table = excel_open.sheet_by_name('Sheet1')
        rows = table.nrows
        for i in range(2, rows):
            row_content = table.row_values(i)
            GrpName=row_content[2]
            GrpIDType = row_content[3]
            GrpPropNo = row_content[4]
            SumNumPeople = int(row_content[5])
            MainBusiness = row_content[6]
            GrpNature = row_content[7]
            BusiCategory = row_content[8]
            Phone1 = int(row_content[9])
            ProvinceName = row_content[10]
            CityName = row_content[11]
            CountyName = row_content[12]
            DetailAddress = row_content[13]
            ZipCode=int(row_content[14])
            policyholder.Applicant(self,GrpName,GrpIDType,GrpPropNo,SumNumPeople,MainBusiness,GrpNature,BusiCategory,Phone1,ProvinceName,CityName,CountyName
                   ,DetailAddress,ZipCode)
    def test08(self):
        print('联系人信息')
        filename = '..//TestData//policyholderifm.xlsx'
        excel_open = xlrd.open_workbook(filename)
        table = excel_open.sheet_by_name('Sheet1')
        rows = table.nrows
        for i in range(2, rows):
            row_content = table.row_values(i)
            LinkMan = row_content[15]
            Phone2 = int(row_content[16])
            EMail = row_content[17]
            MobilePhone = int(row_content[18])
            Department = row_content[19]
            policyholder.LinkManifm(self,LinkMan,Phone2,EMail,MobilePhone,Department)
    def test09(self):
        print('付款银行信息')
        filename = '..//TestData//policyholderifm.xlsx'
        excel_open = xlrd.open_workbook(filename)
        table = excel_open.sheet_by_name('Sheet1')
        rows = table.nrows
        for i in range(2, rows):
            row_content = table.row_values(i)
            PayType = row_content[20]
            BankCode = row_content[21]
            BankProvince = row_content[22]
            BankCity = row_content[23]
            BankAccNo = int(row_content[24])
            AccName = row_content[25]
            policyholder.Bankmsg(self,PayType,BankCode,BankProvince,BankCity,BankAccNo,AccName)
    def test10(self):
        print('开票信息')
        filename = '..//TestData//policyholderifm.xlsx'
        excel_open = xlrd.open_workbook(filename)
        table = excel_open.sheet_by_name('Sheet1')
        rows = table.nrows
        for i in range(2, rows):
            row_content = table.row_values(i)
            InvoiceType = row_content[26]
            TaxPayerType = row_content[27]
            TaxPayerNo = row_content[28]
            TaxPayerNumberNo = row_content[29]
            GSAddress = row_content[30]
            GSTel = row_content[31]
            GSBankCode = row_content[32]
            GSAccNo = int(row_content[33])
            policyholder.Invoice(self,InvoiceType,TaxPayerType,TaxPayerNo,TaxPayerNumberNo,GSAddress
                                  ,GSTel,GSBankCode,GSAccNo)
    def test11(self):
        print('保单经办人信息')
        filename = '..//TestData//policyholderifm.xlsx'
        excel_open = xlrd.open_workbook(filename)
        table = excel_open.sheet_by_name('Sheet1')
        rows = table.nrows
        for i in range(2, rows):
            row_content = table.row_values(i)
            PolicytorName = row_content[39]
            PolicytorIDType = row_content[40]
            PolicytorIDNo = int(row_content[41])
            PolicytorEmail = row_content[42]
            PolicytorPhone = int(row_content[43])
            policyholder.Policytorifm(self,PolicytorName,PolicytorIDType,PolicytorIDNo,PolicytorEmail,
                     PolicytorPhone)
    def test12(self):
        print('企业经办人信息')
        filename = '..//TestData//policyholderifm.xlsx'
        excel_open = xlrd.open_workbook(filename)
        table = excel_open.sheet_by_name('Sheet1')
        rows = table.nrows
        for i in range(2, rows):
            row_content = table.row_values(i)
            ComOperator = row_content[34]
            OperatorEmail = row_content[35]
            OperatorTel = int(row_content[36])
            OperatorPhone = int(row_content[37])
            OperatorDepart = row_content[38]
            policyholder.ComOperatorifm(self,ComOperator,OperatorEmail,OperatorTel,
                       OperatorPhone,OperatorDepart)
    def test13(self):
        print('法人信息')
        filename = '..//TestData//policyholderifm.xlsx'
        excel_open = xlrd.open_workbook(filename)
        table = excel_open.sheet_by_name('Sheet1')
        rows = table.nrows
        for i in range(2, rows):
            row_content = table.row_values(i)
            Corporation = row_content[44]
            CorIDType = row_content[45]
            CorID = row_content[46]
            CorProvinceName = row_content[48]
            CorCityName = row_content[49]
            CorCountyName = row_content[50]
            CorDetailAddress = row_content[51]
            policyholder.Corporationifm(self,Corporation,CorIDType,CorID,CorProvinceName,
                       CorCityName,CorCountyName,CorDetailAddress)
            policyholder.overaction(self)



if __name__ =='__main__':
    # unittest.main()
    suite = unittest.TestLoader.loadTestsFromTestCase(Test_Policyholder)
    unittest.TextTestRunner().run(suite)
